#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void inputString(const char * prompt, char * input)
{
	input[0] = 0;
	printf("%s", prompt);
	scanf("%[^\n]", input);
	fflush(stdin);
}
void string_cleaning(char * string)
{
	int i, count=0;
	for(i=strlen(string)-1; i>-1; i--)
	{
		if(!isspace(string[i]))
		{
			string[i+1]=0;
			break;
		}
	}
	for(i=0; i<strlen(string); i++)
	{
		if(isspace(string[i])) count++;
	}
	memmove(string, string + count, (strlen(string) + 1 - count)*sizeof(char));
}
void main()
{
	FILE * outFile = NULL;
	char string[1000]="", outfile[1000]="";
	inputString("Input string: ", string);
	//inputString("Input output file name: ", outfile);
	string_cleaning(string);
	/*outFile=fopen(outfile, "w");
	fputs(string, outFile);
	fclose(outFile);*/
	printf("Cleaned string: '%s'\n", string);
	system("PAUSE");
}
